package com.ddy.test.kotlintest.utils

import android.content.ContentResolver
import android.content.Context
import android.net.Uri

class CommonUtils {

    // https://www.codota.com/code/java/methods/android.content.res.Resources/getResourcePackageName

    fun getUriFromDrawableResId (context: Context, drawableResId: Int): Uri {

        val stringBuffer: StringBuffer = StringBuffer().append(ContentResolver.SCHEME_ANDROID_RESOURCE)
            .append("://")
            .append(context.getResources().getResourcePackageName(drawableResId))
            .append("/")
            .append(context.getResources().getResourceTypeName(drawableResId))
            .append("/")
            .append(context.getResources().getResourceEntryName(drawableResId))

        return Uri.parse(stringBuffer.toString())

    }

}